package com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.persenter;

import android.animation.ValueAnimator;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;

import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.bean.HistoricalRecordBean;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.model.FirstChangeSearchModel;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.model.ISFirstChangeSearchModel;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeSearch.view.ISFirstChangeSearchView;

import java.util.List;

/**
 * 杭州惟君医疗科技有限公司11
 * Created by 20433 on 2018/3/15
 */

public class FirstChangeSearchPersenter {
    private ISFirstChangeSearchView mISFirstChangeSearchView;
    private ISFirstChangeSearchModel mSetPasswordModel;
    private ValueAnimator animator1;

    public FirstChangeSearchPersenter(ISFirstChangeSearchView iSFirstChangeSearchView) {
        this.mISFirstChangeSearchView = iSFirstChangeSearchView;
        mSetPasswordModel = new FirstChangeSearchModel();
    }
    // 点击取消
    public void onClickcancel(){
        mISFirstChangeSearchView.cancel();
    }
    //点击删除
    public void onClickDelect(){
        mISFirstChangeSearchView.setInputInformation("搜索设备");
    }
    //点击清除记录
    public void onClickClearRecord(){
        mSetPasswordModel.delectAllDate();
    }
    // 初始化 热门数据
    public void initRecyclerviewHotSearch(RecyclerView activityFirstChangeSearchRecyclerviewHotSearch){
        List<HistoricalRecordBean> mlist = mSetPasswordModel.getHotSearch();


    }
    //初始化 历史记录
    public  void  initRecyclerviewSearchHistory(RecyclerView activityFirstChangeSearchRecyclerviewSearchHistory){
        List<HistoricalRecordBean> mbean =   mSetPasswordModel.getSearchHistory();
    }
    public void progressBarAnimation(final ProgressBar activityFirstChangeSearchProgressBar) {
        // 设置数值集合
        animator1 = ValueAnimator.ofInt(0, 100);
        if(animator1.isRunning()){
            animator1.cancel();
        }else{
            // 设置作用对象
            animator1.setTarget(activityFirstChangeSearchProgressBar);
            // 设置执行时间(1000ms)
            animator1.setDuration(1000);
            // 添加动画更新监听
            animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    // 获取当前值
                    int mValue = (int) animation.getAnimatedValue();
                    // 设置横向偏移量
                    activityFirstChangeSearchProgressBar.setProgress(mValue);
                }
            });
            // 开始动画
            animator1.start();
        }
    }
}
